package com.mars.foodserver.controller.app;


import com.mars.foodserver.request.UserRequest;
import com.mars.foodserver.request.WeixinUserRequest;
import com.mars.foodserver.response.result.R;
import com.mars.foodserver.service.IUserService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * User 控制层
 *
 * @Author wq
 * @Date 2021-03-16
 **/
@RestController
@RequestMapping("/user")
@AllArgsConstructor
public class UserController {

    private final IUserService userService;


    /**
     * 微信登录
     *
     * @param request 请求参数
     * @return R
     */
    @PostMapping("/login/weixin")
    private R loginByWeixin(@RequestBody WeixinUserRequest request) {
        return R.success(userService.loginByWeixin(request));
    }


    /**
     * 退出登录
     *
     * @param request 请求参数
     * @return R
     */
    @GetMapping("/logout")
    public R logout(HttpServletRequest request) {
        userService.logout(request);
        return R.success();
    }


}